package tutorial.lite_mod.system_use.feie_print;

import com.wholefarm.print.feie.Tool4FeiePrint;
import org.apache.ibatis.session.SqlSession;
import org.apache.log4j.Logger;
import public_util.model.PublicGoodsOrderRecord;
import public_util.model.ReturnData;
import system_api_4_trade.DuzikaiSpecialApplicationFactory;
import system_api_4_trade.SpecialApplicationBefore;
import system_api_4_trade.dao.ApiPublicGoodsOrderDetailMapper;
import system_api_4_trade.dao.ApiPublicGoodsOrderRecordMapper;
import system_api_4_trade.tool_4_handle.Tool4OrderTemplate;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;

/**
 * 传递特殊参数, 可以演示的模板部分
 * 后面大部分的配置, 都是前端自己传过来比较稳妥
 * 每个传参对应一个相应的方法
 */
public class TemplateUtilApi {

    private static Logger logger = Logger.getLogger(TemplateUtilApi.class.getName());


    /**
     * 打印机的参数从外面传过来, 打印账号， 项目可以自己配置
     * 后面大部分的配置, 都是前端自己传过来比较稳妥
     * 飞鹅打印机的部分
     * 参数一:
     * 参数二:
     *
     * @return
     */
    public static ReturnData pre_cmd_para_show_fei_e_print(PublicGoodsOrderRecord record, HttpServletRequest request, SqlSession session, HashMap<String, Object> params2db, ReturnData resultData)
    {


        String pre_cmd_para_show_fei_e_print = request.getParameter("pre_cmd_para_show_fei_e_print");
        if ("true".equals(pre_cmd_para_show_fei_e_print))
        {
            SpecialApplicationBefore before = DuzikaiSpecialApplicationFactory.load_before_application();
            String[] user_print_login = before.feie_printer_login_user(-1);
            String pre_cmd_para_SN = request.getParameter("pre_cmd_para_SN");
            if (pre_cmd_para_SN == null)
            {
                ReturnData returnData = new ReturnData();
                returnData.setMsg("没有传入SN编号");
            }

            String content_4_order = "<DIRECTION>1</DIRECTION>";
            content_4_order += "<TEXT x=\"24\" y=\"10\" font=\"12\" w=\"1\" h=\"1\" r=\"0\">三和美食(1/10)</TEXT>";
            content_4_order += "<TEXT x=\"24\" y=\"40\" font=\"12\" w=\"1\" h=\"1\" r=\"0\">胡大侠**2301</TEXT>";
            content_4_order += "<TEXT x=\"24\" y=\"80\" font=\"12\" w=\"1\" h=\"2\" r=\"0\">菲力牛排(实惠套餐)</TEXT>";
            content_4_order += "<TEXT x=\"24\" y=\"150\" font=\"12\" w=\"1\" h=\"1\" r=\"0\">上海市嘉定区瑞林路1280弄</TEXT>";
            content_4_order += "<TEXT x=\"24\" y=\"180\" font=\"12\" w=\"1\" h=\"1\" r=\"0\">57号四号楼102室内</TEXT>";
            content_4_order += "<TEXT x=\"24\" y=\"215\" font=\"12\" w=\"1\" h=\"1\" r=\"0\">2020-07-02 14:55:39</TEXT>";

            String method1 = Tool4FeiePrint.print(pre_cmd_para_SN, user_print_login[0], user_print_login[1], content_4_order, "Open_printLabelMsg");
            logger.info("打印的最终结论:" + method1);
        }

        return null;
    }

}

